<html xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:t="http://myfaces.apache.org/tomahawk">

<f:view>
<f:loadBundle var="text" basename="#{userList.bundleName}"/>
<head>
    <title>#{text['userList.title']}</title>
    <meta name="heading" content="#{text['userList.heading']}"/>
    <meta name="menu" content="AdminMenu"/>
</head>

<h:form id="editUser">

<h:commandButton value="#{text['button.add']}" action="#{userForm.add}" id="add" styleClass="button">
    <f:param name="from" value="list"/>
</h:commandButton>
<h:commandButton value="#{text['button.done']}" action="mainMenu" id="cancel"
    immediate="true" styleClass="button" style="margin-left: 5px"/>

<!-- Error from this table is caused by http://issues.apache.org/jira/browse/TOMAHAWK-466 -->
<t:dataTable id="users" var="user" style="margin-top: 10px"
    value="#{userList.users}" rows="25" sortColumn="#{userList.sortColumn}"
    sortAscending="#{userList.ascending}" styleClass="scrollerTable table"
    headerClass="standardTable_Header" rowClasses="standardTable_Row1,standardTable_Row2"
    columnClasses="standardTable_Column,standardTable_Column,standardTable_Column,standardTable_Column,standardTable_ColumnCentered">
    <t:column width="25%">
        <f:facet name="header">
            <t:commandSortHeader columnName="username" arrow="true">
                <h:outputText value="#{text['user.username']}" />
            </t:commandSortHeader>
        </f:facet>
        <h:commandLink action="#{userForm.edit}" value="#{user.username}" >
            <f:param name="id" value="#{user.id}"/>
            <f:param name="from" value="list"/> 
        </h:commandLink>
    </t:column>
    <t:column width="34%">
        <f:facet name="header">
            <t:commandSortHeader columnName="fullName" arrow="true">
                <h:outputText value="#{text['activeUsers.fullName']}" />
            </t:commandSortHeader>
        </f:facet>
        <h:outputText value="#{user.fullName}" />
    </t:column>
    <t:column width="25%">
        <f:facet name="header">
            <t:commandSortHeader columnName="email" arrow="true">
                <h:outputText value="#{text['user.email']}" />
            </t:commandSortHeader>
        </f:facet>
        <h:outputLink value="mailto:#{user.email}">
            <h:outputText value="#{user.email}" />
        </h:outputLink>
    </t:column>
    <t:column width="16%">
        <f:facet name="header">
            <t:commandSortHeader columnName="enabled" arrow="true">
                <h:outputText value="#{text['user.enabled']}" />
            </t:commandSortHeader>
        </f:facet>
        <h:selectBooleanCheckbox value="#{user.enabled}" disabled="true"/>
    </t:column>
</t:dataTable>

<ui:include src="/common/tableFooter.xhtml">
    <ui:param name="tableName" value="users"/> 
</ui:include>

<script type="text/javascript">
    highlightTableRows("editUser:users"); // doesn't currently work to allow clicking row
</script>

</h:form>
</f:view>
</html>